#ifndef _TIMER_HPP_
#define	_TIMER_HPP_
/*******************************************************************************
 ** Name: timer.hpp                                                           **
 ** Description: Timer and timing objects.                                    **
 **                                                                           **
 ** Open Source Initiative (OSI) Approved License                             **
 **                                                                           **
 ** The contents of this file are subject to the terms of the                 **
 ** Common Development and Distribution License, Version 1.0 only             **
 ** (the "License").  You may not use this file except in compliance          **
 ** with the License.                                                         **
 **                                                                           **
 ** You can find a copy of the license in the LICENSE file within             **
 ** this distribution or at $WIKI/display/GOVT/License-software.              **
 ** Software distributed under the License is distributed on an "AS IS"       **
 ** basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.           **
 ** See the License for the specific language governing permissions           **
 ** and limitations under the License.                                        **
 **                                                                           **
 ** When distributing Covered Code, include this CDDL header in each          **
 ** file and include the License file at $GAME_DIR/LICENSE.                   **
 ** If applicable, add the following below this header, with the indicated    **
 ** fields enclosed by brackets "[]" replaced with your own identifying       **
 ** information: Portions Copyright [yyyy] [name of copyright owner]          **
 **                                                                           **
 **                                                                           **
 ** Copyright (c) 2009-2011  Barry Gian James <gian@gamingods.net>            **
 ** All rights reserved.                                                      **
 ******************************************************************************/
// Created on March 16, 2010, 9:45 PM
// Modified $Date: 2012-07-27 19:06:32 -0600 (Fri, 27 Jul 2012) $ by $Author: unknown $

// Portions Copyright 2012 Open Design Strategies, LLC
// All Rights Reserved.
#define timer_hpp_ID   "$Id: timer.hpp 68814 2012-07-28 01:06:32Z unknown $"

#include <boost/chrono.hpp>
using boost::chrono;

class Timer
{
public:
	void		Start() { _start = boost::chrono::system_clock::now(); }
	boost::chrono::duration<long> Elapsed() {
		return boost::chrono::system_clock::now() - _start;
	}
private:
	boost::chrono::system_clock::time_point _start;
	boost::chrono::duration<long> _duration;

};



//extern "C" {
//#include <signal.h>
//#include <time.h>
//#include <errno.h>
//typedef void (*sigFunc)(int,siginfo_t*,void*);
//}
//#include <boost/signals2>
//
//#define TIMER_OK	0
//#define TIMER_ERROR	-1
//#define TIMER_TICK_INTERVAL	30
//#define TIMER_RESET_INTERVAL 180
//#define TIMER_RESET_INTERVAL_INUSE 900
//#define TIMER_INTERVAL_MAX	8	// max array size for intervals
////! @class Timer
////! @brief Time manipulation class
////! POSIX.1b interval timer manipulation class with some other timer junk
////! thrown in for good (or bad) measure.
////! timer_create, timer_settime, timer_gettime, timer_getoverrun, timer_delete
////! sigevent, sigval, itimerspec, timespec, tm, timer_t, sigaction
////! All these functions return 0 on success.
//class Timer
//{
//public:
//	// timer_create() in constructor
//	// Can also pass in a monotonic or thread-specific cpu clock here
//    Timer(int, sigFunc, int = _id, clock_t = CLOCK_REALTIME);
//    // timer_delete in destructor
//    ~Timer();
//
//    // timer_settime() in run(). Can be:
//    int		Run(time_t,long,long);	// ABSOLUTE time
//    int		Run(long,long,long,long);	// RELATIVE time
//    int		Stop();
//    // timer_getoverrun()
//    int		Overrun();
//    // timer_gettime()
//    int		Remaining(long &,long &);
//    long	Elapsed();
//    int		MinPastHour() { return minPastHour; }
//    void	MinPastHour(int mph) { minPastHour = mph; }
//
//    //! returns instantaneous time in seconds since epoch
//    static time_t	Now() { return time(NULL); }
//
//    //! takes two epoch times and returns tm struct with difference/ie
//    //! the amount of time in between the two timestamps
//    tm	*	TimeDelta(bool,time_t,time_t);
//
//    void    Alarm(int sec);
//
//    int operator ! () { return status != 0; }
//    friend std::ostream & operator << (std::ostream &,const Timer &);
//
//private:
//    timer_t		handle;
//    int			status;		//! status value of constructor-related functions
//    itimerspec	spec;
//    // auto-increment our timer id for each timer object to be unique
//    int			timerID;
//    int			minPastHour;	// ie 15 = 10:15,11:15,12:15, etc
//
//    static int _id;
//    static int incr() { return ++_id; }
//};
//
//enum class Month { Jan, Feb, Mar, Apr, May, June, July, Aug,
//	Sept, Oct, Nov, Dec,
//	max
//};
//struct MonthStrings
//{
//	const char *	month;
//	const char *	abbr;
//};
//enum class TimeofDayHour { Sunrise = 5, Daytime = 8, Noon = 12, Sunset = 18, Nighttime = 21, Midnight = 0 };
//enum class TimeofDay { Sunrise, Daytime, Noon, Sunset, Nighttime, Midnight };
//extern const char * TimeofDayStr[];
//
////! @class TimeManager
////! @brief Manages all the TIMES in the game.  Big task.
//class TimeManager
//{
//public:
//	// ctor: initializes with either a new date or from a previous one
//	TimeManager(int m, int h, int d, int mo, int y);
//
//	const char *	MonthStr(Month m) { return monthName[(int)m].month; }
//	const char *	DaySuffix(int day);
//	const char *	DiscordianDate(const char * fmt, bool kb, bool pb);
//
//	// the only public interface into changing the game time
//	// this should get updated every 15s by a global timer
//	int	IncrMin();
//
//	static struct ti {
//		int	min;
//		int	hour;
//		int	day;
//		int	month;
//		int year;
//	} timeInfo;
//
//	ti		GetTimeOfDay() { return timeInfo; }
//
//private:
//	bool	bDoAbsolute;	// if true, based on like 15 after hour else based
//							// on relative time lapse from start of check
//	int		secIntervals[TIMER_INTERVAL_MAX];
//	static MonthStrings monthName[];
//	int		IncrHour();
//	int		IncrDay();
//	int		IncrMonth();
//	int		IncrYear();
//
//};

#endif	/* _TIMER_HPP */

